import java.io.*;

class MotionResult
{
    public MotionResult(String filename, MatLabArray w1, MatLabArray w2,
    MatLabArray warped, Matrix costs, MatLabArray path)
    {
        FileOutputStream out;
        PrintStream p;

        w1.toFile(filename);
        w2.toFile(filename,true);
        warped.toFile(filename,true);
        costs.matLabToFile(filename,true);
        path.toFile(filename,true);

        try
        {
            out = new FileOutputStream(filename, true);
            p = new PrintStream( out );
            p.println("close all");
            p.println("hold off");
            p.println("plot("+w1.name+",'r')");
            p.println("hold on");
            p.println("plot("+w2.name+",'g')");
            p.println("plot("+warped.name+",'b')");
            p.println("hold off");
            p.println("figure");
            p.println("imagesc("+costs.getName()+")");
            p.println("hold on");
            p.println("plot("+path.name+",'w')");
            p.println("xlabel('Warpable Signal (B)')");
            p.println("ylabel('Template Signal (A)')");

            p.close();
        }
        catch (Exception e)
        {
            System.err.println ("Error writing array to specified file.");
        }
    }
}
